Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

[WIP] Feature/micromap #1230

Closed
wants to merge 11 commits into from
Closed

Conversation

rkirov
Copy link
Contributor

@rkirov rkirov commented Jul 14, 2014

Rebased on top of #1208 (original micro map) and #1178 (view perf improvements).

tree benchmark (with dart2js):
pr 1178 (baseline) - 470ms +/- 12%, 42.6 Mb heap
this PR - 450ms +/- 12%, 41.8 Mb heap

The confidence intervals are quite large so I am not sure if this is indeed better or we are looking into noise. Also, running the benchmark for extended period seems to affect the numbers significantly (as some point I saw the baseline drop to 430ms itself).

More work needs to be done on the iterators (they should be views into the micromaps, instead of holding their own values).

(profile-baseline)
profile-baseline

(profile-pr)
profile-pr

(baseline heap)
pr1178-snapshot

(micromap heap)
micromap-heap-prof

@rkirov rkirov added cla: yes and removed cla: no labels Jul 14, 2014
@rkirov rkirov mentioned this pull request Jul 14, 2014
@rkirov
Copy link
Contributor Author

rkirov commented Jul 14, 2014

Example of differences between MicroMap and HashMap due to Iterables:

  var map = new *Map<num, num>();                                             
  var it = map.keys.iterator;                                                    
  map[1] = 1;                                                                    
  it.moveNext(); 

MicroMap - fine
HashMap - throws 'modification during iteration'

    var map = new *Map<num, num>();
    map[1] = 1;
    var it = map.values.iterator;
    map[1] = 2;
    it.moveNext();
    print(it.current);

MicroMap - 1
HashMap - 2

@mhevery
Copy link
Contributor

mhevery commented Jul 21, 2014

@rkirov Can you squash all of the SHAs into a single SHA.

mvuksano and others added 11 commits August 7, 2014 16:34
…ay and after a number of elements is inserted switches to a HashMap implementation.

MicroMap is intended to be used when one expects that the number of elements will be quite low. In this setting it's better to use an array and use linear search to locate elements rather then using the actual HashMap. After a certain number of elements have been inserted HashMap will perform better then array and linear search.

Worst case scenario will be when the number of elements keeps oscillating around threshold value which will cause the map to keep switching from array to HashMap (and vice versa). Switching form array to hashMap and the other way around is an expensive operation.

Closes dart-archive#1201
Null keys are acceptable for HashMap, so MicroMap needs to keep that
feature.

Also now it stays in delegate mode once it has been switched.
MicroIterators were not conforming to iterator interface. Replaced by
simply promoting micromap to Map in iterator getters.
@jbdeboer
Copy link
Contributor

We could not find a performance improvement here. Closing

@jbdeboer jbdeboer closed this Aug 25, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

4 participants